package com.xingkeduo.controller;

import com.xingkeduo.service.TimingTaskService;
import com.xingkeduo.util.TimeUtil;
import com.xingkeduo.util.tool.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Description TODO
 * @Date 2019/5/24 14:30
 * @Created 情绪十分不稳定的Shadow
 */

@RestController
@RequestMapping("/timing/task")
public class TimingTaskController {

    @Autowired
    private TimingTaskService timingTaskService;

    /**
     * @description 定时打卡任务
     * @Author 情绪极其不稳定的Shadow
     * @Param []
     * @return com.xingkeduo.util.tool.ResponseMessage
     **/
    @GetMapping("/clockTask")
    public ResponseMessage clockTask(){
        int i = timingTaskService.clockTask();
        if(i > 0){
            return ResponseMessage.ok("定时打卡任务成功！");
        }
        return ResponseMessage.error("定时打卡任务异常 or "+ TimeUtil.DateToFormat(new Date(), "yyyy-MM-dd HH:mm:ss")+"无漏卡");
    }

    /**
     * @description 定时排班任务
     * @Author 情绪极其不稳定的Shadow
     * @Param []
     * @return com.xingkeduo.util.tool.ResponseMessage
     **/
    @GetMapping("/attendanceTask")
    public ResponseMessage attendanceTask(){
        timingTaskService.attendanceTask();
        return ResponseMessage.ok("定时排班任务成功！");
    }
}
